<template>
  <div id="ipt">
    <textarea
      placeholder="说点什么吧..."
      resize="none"
      cols="80"
      rows="5"
      v-model="content"
    ></textarea>
    <div class="action">
      <button @click="addComment">发送评论</button>
    </div>
  </div>
</template>
<script>
import * as api from "@/api/comment";
import { mapActions } from "vuex";
export default {
  data() {
    return {
      content: "",
      name: "ikun",
    };
  },
  methods: {
    ...mapActions("comment", ["FETCH_COMMENT"]),
    async addComment() {
      let res = await api.addComment(this.content, this.name);
      console.log(res);
      if (res.data.state) {
        this.FETCH_COMMENT();
      }
    },
  },
};
</script>
<style scoped></style>
